<?php
namespace app\api\controller;

use support\Request;
use think\facade\Db;
use utils\Jwt;
use think\facade\Cache;


class CommonController{
	
	
	protected $request = null;
	
	protected $config = null;
		
	
	public function beforeAction(Request $request){
		$this->request = $request;
		$this->config = Cache::get('base_config');
    }
	
	/**
     * 生成token
     * @param  userinfo 用户信息
     */
	protected function setToken($userinfo){
		$jwt = Jwt::getInstance();
		$jwt->setIss(config('my.jwt_iss'))->setAud(config('my.jwt_aud'))->setSecrect(config('my.jwt_secrect'))->setExpTime(config('my.jwt_expire_time'));
		$token = $jwt->setUid($userinfo)->encode()->getToken();
		return $token;
	}
	
	
    

}
